﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOABLL;
using TarreOA.TarreOAModels;

public partial class admin_Flow_BackManage_FlowStepList : System.Web.UI.Page
{
    static List<Flow_NewFlowStep> list = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Flow_NewFlow nf = Flow_NewFlow_Service.FindByFlowId(Convert.ToInt32(Request.QueryString["id"]));
            Label1.Text = "新建流程步骤 ("+nf.NewFlow_name+")";
            Label2.Text = "管理流程步骤 (" + nf.NewFlow_name + ")";
            list = Flow_NewFlowStep_Service.FindFlowStepByFlowId(Convert.ToInt32(Request.QueryString["id"]));
            GridView1.DataSource = list;
            if (Request.QueryString["pageIndex"]!=null && Request.QueryString["pageIndex"]!="")
            {
                GridView1.PageIndex = Convert.ToInt32(Request.QueryString["pageIndex"]);
            }
            GridView1.DataBind();
        }
    }
    protected void btnAddFlowStep_Click(object sender, EventArgs e)
    {
        Response.Redirect("AddFlowStep.aspx?id="+Request.QueryString["id"]);
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName=="updateFlowStep")
        {
            Response.Redirect("UpdateFlowStep.aspx?id="+Request.QueryString["id"]+"&fid="+e.CommandArgument.ToString()+"&pageIndex="+GridView1.PageIndex.ToString());
        }
        else if (e.CommandName=="updateManager")
        {
            Response.Redirect("UpdateFlowStepManager.aspx?id=" + Request.QueryString["id"] + "&fid=" + e.CommandArgument.ToString() + "&pageIndex=" + GridView1.PageIndex.ToString());
        }
        else if (e.CommandName == "updateSections")
        {
            Response.Redirect("UpdateFlowStepSections.aspx?id=" + Request.QueryString["id"] + "&fid=" + e.CommandArgument.ToString() + "&pageIndex=" + GridView1.PageIndex.ToString());
        }
        else if (e.CommandName == "updateRoles")
        {
            Response.Redirect("UpdateFlowStepRoles.aspx?id=" + Request.QueryString["id"] + "&fid=" + e.CommandArgument.ToString() + "&pageIndex=" + GridView1.PageIndex.ToString());
        }
        else if (e.CommandName == "updateInputs")
        {
            Response.Redirect("UpdateFlowStepInputs.aspx?id=" + Request.QueryString["id"] + "&fid=" + e.CommandArgument.ToString()+"&pageIndex="+GridView1.PageIndex.ToString());
        }
        else if (e.CommandName=="delFlowStep")
        {
            if (Flow_NewFlowStep_Service.DelFlowStep(Convert.ToInt32(e.CommandArgument)))
            {
                int pageIndex = GridView1.PageIndex;
                list = Flow_NewFlowStep_Service.FindFlowStepByFlowId(Convert.ToInt32(Request.QueryString["id"]));
                GridView1.DataSource = list;
                GridView1.PageIndex = pageIndex;
                GridView1.DataBind();
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败！请重试！')", true);
            }
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataSource = list;
        GridView1.DataBind();
    }
}
